///


cc.Class({
    extends: cc.Component,
    properties: {
        downTimeFactor:{
            default: 5,
            type:cc.Float,
        },

        RegainSpeed: 320, 
        isRegaining: {
            default: false,
            visible: false,
        },
        mEndUI: cc.Node,
        mController: cc.Node,
    },

    // LIFE-CYCLE CALLBACKS:
    // onLoad () {},

    start () {

        // this.startLine();
    },

    startAnim() {

    },

    startLine() {

        this.node.stopAllActions();
        this.node.runAction(cc.repeatForever(cc.moveBy(this.downTimeFactor,cc.v2(0,-100))));
        this.isRegaining = false;
    },

    regainLine() {  // 收杆

        if(this.isRegaining) 
            return;
        

        let self = this;
        this.node.stopAllActions();
        let duratiron = Math.abs(this.node.y) / this.RegainSpeed;
        if(duratiron < 2)
            duratiron = 2;

        cc.log("regainLine() ->",duratiron);
        this.node.runAction(cc.sequence(
            cc.moveTo(duratiron,cc.v2(0,0)).easing(cc.easeSineIn()),
            cc.callFunc(function() {
                let ui = self.mEndUI.getComponent("EndUI");
                ui.show();
            })
        ));
            
        this.isRegaining = true;

    },
    // update (dt) {},

    enableTouch() {


    },

    disableTouch() {

    },
});
